package java复习202503.D_反射;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {

    public static void main(String[] args) {
        Demo demo = new Demo();

        Class<? extends Demo> aClass = demo.getClass();

        Field[] fields = aClass.getFields();
        Method[] methods = aClass.getMethods();


        String name = fields[0].getName();
        System.out.println(name);


        try {
            methods[0].invoke(Demo.class,null);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

    }
}
